package com.ruoyi.system.service.impl.basic;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.basic.BasicCargoTypesMapper;
import com.ruoyi.system.domain.db.basic.BasicCargoTypes;
import com.ruoyi.system.service.IBasicCargoTypesService;

/**
 * 货物类型Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-07-25
 */
@Service
public class BasicCargoTypesServiceImpl implements IBasicCargoTypesService 
{
    @Autowired
    private BasicCargoTypesMapper basicCargoTypesMapper;

    /**
     * 查询货物类型
     * 
     * @param cargoTypeId 货物类型主键
     * @return 货物类型
     */
    @Override
    public BasicCargoTypes selectBasicCargoTypesByCargoTypeId(Integer cargoTypeId)
    {
        return basicCargoTypesMapper.selectBasicCargoTypesByCargoTypeId(cargoTypeId);
    }

    /**
     * 查询货物类型列表
     * 
     * @param basicCargoTypes 货物类型
     * @return 货物类型
     */
    @Override
    public List<BasicCargoTypes> selectBasicCargoTypesList(BasicCargoTypes basicCargoTypes)
    {
        return basicCargoTypesMapper.selectBasicCargoTypesList(basicCargoTypes);
    }

    /**
     * 新增货物类型
     * 
     * @param basicCargoTypes 货物类型
     * @return 结果
     */
    @Override
    public int insertBasicCargoTypes(BasicCargoTypes basicCargoTypes)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        basicCargoTypes.setCreateBy(loginUser.getUserId());
        basicCargoTypes.setUpdateBy(loginUser.getUserId());
        basicCargoTypes.setCreateTime(DateUtils.getNowDate());
        basicCargoTypes.setUpdateTime(DateUtils.getNowDate());
        return basicCargoTypesMapper.insertBasicCargoTypes(basicCargoTypes);
    }

    /**
     * 修改货物类型
     * 
     * @param basicCargoTypes 货物类型
     * @return 结果
     */
    @Override
    public int updateBasicCargoTypes(BasicCargoTypes basicCargoTypes)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        basicCargoTypes.setUpdateTime(DateUtils.getNowDate());
        basicCargoTypes.setUpdateBy(loginUser.getUserId());
        return basicCargoTypesMapper.updateBasicCargoTypes(basicCargoTypes);
    }

    /**
     * 批量删除货物类型
     * 
     * @param cargoTypeIds 需要删除的货物类型主键
     * @return 结果
     */
    @Override
    public int deleteBasicCargoTypesByCargoTypeIds(Integer[] cargoTypeIds)
    {
        return basicCargoTypesMapper.deleteBasicCargoTypesByCargoTypeIds(cargoTypeIds);
    }

    /**
     * 删除货物类型信息
     * 
     * @param cargoTypeId 货物类型主键
     * @return 结果
     */
    @Override
    public int deleteBasicCargoTypesByCargoTypeId(Integer cargoTypeId)
    {
        return basicCargoTypesMapper.deleteBasicCargoTypesByCargoTypeId(cargoTypeId);
    }
}
